package com.ruoyi.project.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mapper.ProjectDemoMapper;
import com.ruoyi.project.domain.ProjectDemo;
import com.ruoyi.project.service.IProjectDemoService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * demoService业务层处理
 *
 * @author ruoyi
 * @date 2022-09-01
 */
@Service
public class ProjectDemoServiceImpl implements IProjectDemoService
{
    @Resource
    private ProjectDemoMapper projectDemoMapper;

    /**
     * 查询demo
     *
     * @param id demo主键
     * @return demo
     */
    @Override
    public ProjectDemo selectProjectDemoById(Long id)
    {
        return projectDemoMapper.selectById(id);
    }

    /**
     * 查询demo列表
     *
     * @param projectDemo demo
     * @return demo
     */
    @Override
    public List<ProjectDemo> selectProjectDemoList(ProjectDemo projectDemo)
    {
        return projectDemoMapper.selectProjectDemoList(projectDemo);
    }

    /**
     * 新增demo
     *
     * @param projectDemo demo
     * @return 结果
     */
    @Override
    public int insertProjectDemo(ProjectDemo projectDemo)
    {
        return projectDemoMapper.insert(projectDemo);
    }

    /**
     * 修改demo
     *
     * @param projectDemo demo
     * @return 结果
     */
    @Override
    public int updateProjectDemo(ProjectDemo projectDemo)
    {

        return projectDemoMapper.updateById(projectDemo);
    }

    /**
     * 批量删除demo
     *
     * @param ids 需要删除的demo主键
     * @return 结果
     */
    /**
     * 批量删除demo
     *
     * @param ids 需要删除的demoID
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteProjectDemoByIds(Long[] ids)
    {
        for(Long id:ids){
            deleteProjectDemoById(id);
        }
        return ids.length;
    }


    /**
     * 删除demo信息
     *
     * @param id demo主键
     * @return 结果
     */
    @Override
    public int deleteProjectDemoById(Long id)
    {
        return projectDemoMapper.deleteProjectDemoById(id);
    }
}
